package com.wans.order.config;

import feign.Logger;
import feign.Retryer;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class OrderConfig {

    /**
     * RestTemplate配置 远程调用
     * @return RestTemplate
     */
    @Bean
    @LoadBalanced //负载均衡 LoadBalanced注解，会自动调用服务发现，获取服务列表，然后随机选择一个服务，调用服务
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * feign重试次数配置
     * @return Retryer
     */
    @Bean
    public Retryer retryer() {
        return new Retryer.Default(100, 1000, 5);
    }

    /**
     * feign日志配置
     * @return Logger.Level
     */
    @Bean
    public Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }
}
